package geppetto.phraseHMM.phraseExtraction.extractedphrase.data;

import geppetto.main.adaptation.AdaptationInfo;
import geppetto.phraseHMM.phraseExtraction.extractedphrase.ExtractedPhrasePair;
import geppetto.phraseHMM.phraseExtraction.extractedphrase.ExtractedPhrasePairData;
import geppetto.phraseHMM.phraseExtraction.extractedphrase.ExtractedPhrasePairDataCalc;

public class AdaptationTypeCalc implements ExtractedPhrasePairDataCalc{

	protected AdaptationInfo adaptInfo;	
	
	public AdaptationTypeCalc(AdaptationInfo adaptInfo) {
		super();
		this.adaptInfo = adaptInfo;
	}

	@Override
	public ExtractedPhrasePairData calcData(ExtractedPhrasePair epp) {
		String[] adaptationTypes = adaptInfo.getSentenceTokenTypes(epp.getSentenceNumber());
		AdaptationTypeData data = new AdaptationTypeData();
		for(int i = epp.getSourceStartPos(); i <= epp.getSourceEndPos(); i++){
			data.insert(adaptationTypes[i], 1d);
		}
		return data;
	}

	@Override
	public ExtractedPhrasePairData loadFromString(String s) {
		return AdaptationTypeData.parseString(s);
	}

}
